// PropertySubWindow.cpp: implementation of the PropertySubWindow class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PropertySubWindow.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace pa
{
	PropertySubWindow::PropertySubWindow()
	{
	    m_pVar = NULL;
	    m_pPropertyWindow = NULL;
	    m_pContext = NULL;

	}

	PropertySubWindow::~PropertySubWindow()
	{

	}

	void PropertySubWindow::SetWindowPosition(const CRect& rect)
{
	ASSERT(m_pContext);
	ASSERT(m_pContext->GetSafeHwnd() != NULL);
	ASSERT(m_Prompt.GetSafeHwnd() != NULL);

	CRect PromptRect;
	CRect ContextRect;

	PromptRect.SetRect(rect.left, rect.top, rect.left + rect.Width()/2, rect.bottom);
	ContextRect.SetRect(rect.left + rect.Width()/2, rect.top, rect.right, rect.bottom);

	if(m_pContext->IsKindOf(RUNTIME_CLASS(CComboBox)))
	{
		CRect rectCon;
		m_pContext->GetWindowRect(&rectCon);
		ContextRect.bottom = ContextRect.top + 160;
	}
	m_pContext->MoveWindow(ContextRect);
	m_Prompt.MoveWindow(PromptRect);
}

BOOL PropertySubWindow::Create(CWnd* pParent, UINT nID)
{
	ASSERT(m_pVar);
	ASSERT(!m_pVar->Prompt().IsEmpty());

	BOOL bResult =  m_Prompt.Create(m_pVar->Prompt(), SS_LEFT|SS_SIMPLE, CRect(0,0,1,1), pParent);
	m_Prompt.ShowWindow(SW_SHOW);
	return bResult;
}

CString PropertySubWindow::ShowString()
{
	ASSERT(m_pVar);

	return (CString)(*(m_pVar->PropertyVar()));
}

void PropertySubWindow::SetFont(CFont* pFont)
{
	m_Prompt.SetFont(pFont);
}

};